<?php

namespace app\modules\clinical\models;

use Yii;

/**
 * This is the model class for table "excel_udprs".
 *
 * @property integer $pk_id
 * @property string $med_time_off
 * @property integer $mdb_amount
 * @property string $med_time_on
 * @property integer $yanyu_off
 * @property integer $yanyu_on
 * @property integer $mianbu_off
 * @property integer $mianbu_on
 * @property integer $zhenc_jz_mian_off
 * @property integer $zhenc_jz_mian_on
 * @property integer $zhenc_jz_zui_off
 * @property integer $zhenc_jz_zui_on
 * @property integer $zhenc_jz_xe_off
 * @property integer $zhenc_jz_xe_on
 * @property integer $zhenc_jz_lu_off
 * @property integer $zhenc_jz_lu_on
 * @property integer $zhenc_jz_ld_off
 * @property integer $zhenc_jz_ld_on
 * @property integer $zhenc_jz_ru_off
 * @property integer $zhenc_jz_ru_on
 * @property integer $zhenc_jz_rd_off
 * @property integer $zhenc_jz_rd_on
 * @property integer $zhenc_shou_ru_off
 * @property integer $zhenc_shou_ru_on
 * @property integer $zhenc_shou_lu_off
 * @property integer $zhenc_shou_lu_on
 * @property integer $qiangz_j_off
 * @property integer $qiangz_j_on
 * @property integer $qiangz_lu_off
 * @property integer $qiangz_lu_on
 * @property integer $qiangz_ld_off
 * @property integer $qiangz_ld_on
 * @property integer $qiangz_ru_off
 * @property integer $qiangz_ru_on
 * @property integer $qiangz_rd_off
 * @property integer $qiangz_rd_on
 * @property integer $paida_l_off
 * @property integer $paida_l_on
 * @property integer $paida_r_off
 * @property integer $paida_r_on
 * @property integer $yund_l_off
 * @property integer $yund_l_on
 * @property integer $yund_r_off
 * @property integer $yund_r_on
 * @property integer $lunti_off
 * @property integer $lunti_on
 * @property integer $tui_l_off
 * @property integer $tui_l_on
 * @property integer $tui_r_off
 * @property integer $tui_r_on
 * @property integer $qili_off
 * @property integer $qili_on
 * @property integer $zishi_off
 * @property integer $zishi_on
 * @property integer $butai_off
 * @property integer $butai_on
 * @property integer $zishi_w_off
 * @property integer $zishi_w_on
 * @property integer $quti_off
 * @property integer $quti_on
 * @property double $hoehn
 */
class ExcelUdprs extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'excel_udprs';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['med_time_off', 'med_time_on'], 'safe'],
            [['yanyu_off', 'yanyu_on', 'mianbu_off', 'mianbu_on', 'zhenc_jz_mian_off', 'zhenc_jz_mian_on', 'zhenc_jz_zui_off', 'zhenc_jz_zui_on', 'zhenc_jz_xe_off', 'zhenc_jz_xe_on', 'zhenc_jz_lu_off', 'zhenc_jz_lu_on', 'zhenc_jz_ld_off', 'zhenc_jz_ld_on', 'zhenc_jz_ru_off', 'zhenc_jz_ru_on', 'zhenc_jz_rd_off', 'zhenc_jz_rd_on', 'zhenc_shou_ru_off', 'zhenc_shou_ru_on', 'zhenc_shou_lu_off', 'zhenc_shou_lu_on', 'qiangz_j_off', 'qiangz_j_on', 'qiangz_lu_off', 'qiangz_lu_on', 'qiangz_ld_off', 'qiangz_ld_on', 'qiangz_ru_off', 'qiangz_ru_on', 'qiangz_rd_off', 'qiangz_rd_on', 'paida_l_off', 'paida_l_on', 'paida_r_off', 'paida_r_on', 'yund_l_off', 'yund_l_on', 'yund_r_off', 'yund_r_on', 'lunti_off', 'lunti_on', 'tui_l_off', 'tui_l_on', 'tui_r_off', 'tui_r_on', 'qili_off', 'qili_on', 'zishi_off', 'zishi_on', 'butai_off', 'butai_on', 'zishi_w_off', 'zishi_w_on', 'quti_off', 'quti_on'], 'integer'],
            [['hoehn', 'mdb_amount'], 'number'],
            [['yanyu_on', 'mianbu_on'], 'required']
        ];
    }

    public function attributeLabels()
    {
        return [
            'med_time_off' => '吃药时间(OFF)',
            'mdb_amount' => '美多芭用量',
            'med_time_on' => '第二次评分时间(ON)',
        ];
    }

    public function defaultValue()
    {
        $this->yanyu_on = 0;
        $this->mianbu_on = 0;
        $this->zhenc_jz_mian_on = 0;
        $this->zhenc_jz_zui_on = 0;
        $this->zhenc_jz_xe_on = 0;
        $this->zhenc_jz_lu_on = 0;
        $this->zhenc_jz_ld_on = 0;
        $this->zhenc_jz_ru_on = 0;
        $this->zhenc_jz_rd_on = 0;
        $this->zhenc_shou_ru_on = 0;
        $this->zhenc_shou_lu_on = 0;
        $this->qiangz_j_on = 0;
        $this->qiangz_lu_on = 0;
        $this->qiangz_ld_on = 0;
        $this->qiangz_ru_on = 0;
        $this->qiangz_rd_on = 0;
        $this->paida_l_on = 0;
        $this->paida_r_on = 0;
        $this->yund_l_on = 0;
        $this->yund_r_on = 0;
        $this->lunti_on = 0;
        $this->tui_l_on = 0;
        $this->tui_r_on = 0;
        $this->qili_on = 0;
        $this->zishi_on = 0;
        $this->butai_on = 0;
        $this->zishi_w_on = 0;
        $this->quti_on = 0;
        $this->med_time_on = '00:00';
    }

    public static function getParams($type = false, $code = false) {
        $params = [
            'yanyu' => ['正常', '表达、理解和( 或) 音量轻度下降', '单音调, 含糊但可听懂, 中度受损', '明显损害, 难以听懂', '无法听懂'],
            'mianbu' => ['正常', '略呆板, 可能是正常的“面无表情”', '轻度但肯定是面部表情差', '中度表情呆板, 有时张口', '面具脸, 几乎完全没有表情, 口张开在1/4 英寸(0.6cm) 或以上'],
            'zhenc_jz' => ['无', '轻度, 有时出现', '幅度小而持续, 或中等幅度间断出现', '幅度中等, 多数时间出现', '幅度大, 多数时间出现'],
            'zhenc_shou' => ['无', '轻度, 活动时出现', '幅度中等, 活动时出现', '幅度中等, 持物或活动时出现', '幅度大, 影响进食'],
            'qiangz' => ['无', '轻度, 或仅在镜像运动及加强试验时可查出', '轻到中度', '明显, 但活动范围不受限', '严重, 活动范围受限'],
            'paida' => ['正常(≥15 次/ 5 秒)', '轻度减慢和(或)幅度减小(11 ～14次/ 5 秒)', '中等障碍, 有肯定的早期疲劳现象,运动中可以有偶尔的停顿(7 ～ 10次/秒)', '严重障碍, 动作起始困难或运动中有停顿(3～6 次/ 5 秒)', '几乎不能执行动作(0～2次/5秒)'],
            'yund' => ['正常', '轻度减慢或幅度减小', '中度障碍, 有肯定的早期疲劳现象,运动中可以有偶尔的停顿', '严重障碍, 动作起始时经常犹豫或运动中有停顿', '几乎不能执行动作'],
            'qili' => ['正常', '缓慢, 或可能需要试1次以上', '需扶扶手站起', '向后倒的倾向, 必须试几次才能站起, 但不需帮助', '没有帮助不能站起'],
            'zishi' => ['正常直立', '不很直, 轻度前倾, 可能是正常老年人的姿势', '中度前倾, 肯定是不正常, 可能有轻度的向一侧倾斜', '严重前倾伴脊柱后突, 可能有中度的向一侧倾斜', '显著屈曲, 姿势极度异常'],
            'butai' => ['正常', '行走缓慢, 可有曳步, 步距小, 但无慌张步态或前冲步态', '行走困难, 但还不需要帮助, 可有某种程度的慌张步态、小步或前冲', '严重异常步态, 行走需帮助', '即使给予帮助也不能行走'],
            'zishi_w' => ['后倾, 无需帮助可自行恢复', '无姿势反应, 如果不扶可能摔倒', '非常不稳, 有自发的失去平衡现象', '不借助外界帮助不能站立'],
            'quti' => ['无', '略慢, 似乎是故意的, 在某些人可能是正常的, 幅度可能减小', '运动呈轻度缓慢和减少, 肯定不正常, 或幅度减小', '中度缓慢, 运动缺乏或幅度小', '明显缓慢, 运动缺乏或幅度小'],
            'hoehn' => ['0' => '无症状', '1' => '单侧疾病', '1.5' => '单侧+躯干受累', '2' => '双侧疾病, 无平衡障碍', '2.5' => '轻微双侧疾病, 后拉试验可恢复', '3' => '轻～中度双侧疾病, 某种姿势不稳,独立生活', '4' => '严重残疾, 仍可独自行走或站立', '5' => '无帮助时只能坐轮椅或卧床'],
        ];

        if ($code !== false) {
            return ($type) ? $params[$type][$code] : '';
        }

        return ($type) ? $params[$type] : $params;
    }
}
